package letsjava.pattern.bridge;

public abstract class Coffee {
	CoffeeImp coffeeImp;
	public static void main(String[] args){
		//拿出牛奶
		CoffeeImpSingleton coffeeImpSingleton = new CoffeeImpSingleton(new MilkCoffeeImp()); 
		
		//中杯加奶
		MediumCoffee mediumCoffee = new MediumCoffee(); 
		mediumCoffee.pourCoffee(); 
		
		//大杯加奶
		SuperSizeCoffee superSizeCoffee = new SuperSizeCoffee(); 
		superSizeCoffee.pourCoffee();
		
	}
	public void setCoffeeImp() {
		this.coffeeImp = CoffeeImpSingleton.getTheCoffeeImp();
	}

	public CoffeeImp getCoffeeImp() {
		return this.coffeeImp;
	}

	public abstract void pourCoffee();
}

class MilkCoffeeImp extends CoffeeImp {
	MilkCoffeeImp() {
	}

	public void pourCoffeeImp() {
		System.out.println("加了美味的牛奶");
	}
}

class FragrantCoffeeImp extends CoffeeImp {
	FragrantCoffeeImp() {
	}

	public void pourCoffeeImp() {
		System.out.println("NO美味的牛奶");
	}
}

class CoffeeImpSingleton {
	private static CoffeeImp coffeeImp;

	public CoffeeImpSingleton(CoffeeImp coffeeImpIn) {
		this.coffeeImp = coffeeImpIn;
	}

	public static CoffeeImp getTheCoffeeImp() {
		return coffeeImp;
	}
}
